<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/security.tld" prefix="s" %>
<script language="javascript">
	 function validate(){
        var errors = "";
        var plantId = document.getElementById('recurrentChargesAddView.plantId').value;
        var transportId = document.getElementById('recurrentChargesAddView.transportId').value;
        var costElementId = document.getElementById('recurrentChargesAddView.costElementId').value;        
        var currencyId = document.getElementById('recurrentChargesAddView.currencyId').value;        
       
        if(plantId == '-1'){
        	errors = '<bean:message key="label.error.message.recurrentcharge.choose.plant"/>\n';
        }

        if(transportId == '-1'){
        	errors = errors + '<bean:message key="label.error.message.recurrentcharge.choose.transport"/>\n';
        }

        if(costElementId == '-1'){
        	errors = errors + '<bean:message key="label.error.message.recurrentcharge.choose.costelement"/>\n';
        }

        if(currencyId == '-1'){
        	errors = errors + '<bean:message key="label.error.message.recurrentcharge.choose.currency"/>\n';
        }
        
        if( errors == "" ){
            return true;
        }else{
            alert( '<bean:message key="label.common.errors"/> : \n' + errors );
			return false;
        }
        
       }

</script>
<html:form action="/saveAddRecurrentCharges" onsubmit="return validate()">
	<table width="100%">
		<tr>
			<td>
				<table align="left" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
					<tr>
						<td colspan="8" align="center" class="titulocolumna">
							<bean:message key="label.versions.adjustValuesToVersionBalance.recurrent.charges"/>
						</td>
					</tr>
					<tr>
						<td class="etiqueta" width="40">
							<bean:message key="label.plants.name"/>:
						</td>
						<td class="etiqueta_campo" width="140">
							<html:select property="recurrentChargesAddView.plantId" styleId="recurrentChargesAddView.plantId" styleClass="campo_texto">
								<html:option value="-1"><bean:message key="label.program.purchase.selectanoption"/></html:option>
								<html:optionsCollection name="PLANT_LIST"  label="shortName" value="plantId"/>
							</html:select>
						</td>
						<td class="etiqueta" width="60">
							<bean:message key="label.transports.query.transport"/>:
						</td>
						<td class="etiqueta_campo"  width="140">
							<html:select property="recurrentChargesAddView.transportId" styleId="recurrentChargesAddView.transportId" styleClass="campo_texto">
								<html:option value="-1"><bean:message key="label.program.purchase.selectanoption"/></html:option>
								<html:optionsCollection name="TRANSPORT_LIST"  label="transportShortName" value="transportIdentifier"/>
							</html:select>
						</td>
						<td class="etiqueta" width="100">
							<bean:message key="label.manual.charges.elementcost"/>:
						</td>
						<td class="etiqueta_campo" width="140">
							<html:select property="recurrentChargesAddView.costElementId" styleId="recurrentChargesAddView.costElementId" styleClass="campo_texto">
								<html:option value="-1"><bean:message key="label.program.purchase.selectanoption"/></html:option>
								<html:optionsCollection name="COST_ELEMENT_LIST"  label="costElementCode" value="costElementID"/>
							</html:select>
						</td>
						<td class="etiqueta" width="60">
							<bean:message key="label.versions.adjustValuesToVersionBalance.recurrent.charges.currency"/>:
						</td>
						<td class="etiqueta_campo" width="140">
							<html:select property="recurrentChargesAddView.currencyId" styleId="recurrentChargesAddView.currencyId" styleClass="campo_texto">
								<html:option value="-1"><bean:message key="label.program.purchase.selectanoption"/></html:option>
								<html:optionsCollection name="CURRENCY_LIST"  label="code" value="currencyId"/>
							</html:select>
						</td>
					</tr>
					<tr>
						<td colspan="8" class="etiqueta_campo">
							<s:entidad nombreCortoEnt="NEW" permiso="ADMINISTRACION" nombreCortoMod="PROC" nombreCortoSub="VERCMR">
							<html:submit styleClass="boton"><bean:message key="label.common.add"/></html:submit>
							</s:entidad>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</html:form>